<template>
    <pageTabelLayout>
        <template #pageHeader>
            <div class="search-form divClass" v-if="headerShow">
                <div>
                    <a-form :model="queryData" size="small" layout="inline">
                        <a-form-item label="开单日期" :style="{ width: '300px' }" label-col-flex="80px">
                            <a-date-picker  popup-container="html"  allow-clear :style="{ width: '250px' }" class="bacClass" placeholder="" v-model="dataForm.beginDate"
                                @press-enter="huiche" />
                        </a-form-item>
                        <a-form-item label="结束日期" :style="{ width: '300px' }" label-col-flex="80px">
                            <a-date-picker  popup-container="html"  allow-clear :style="{ width: '250px' }" class="bacClass" placeholder="" v-model="dataForm.endDate"
                                @press-enter="huiche" />
                        </a-form-item>
                        <a-form-item label="记录单号" :style="{ width: '300px' }" label-col-flex="80px">
                            <a-input allow-clear class="bacClass" placeholder="" v-model="dataForm.recordCode"
                                @press-enter="huiche" />
                        </a-form-item>
                        <a-form-item label="流转卡号" :style="{ width: '300px' }" label-col-flex="80px">
                            <a-input allow-clear class="bacClass" placeholder="" v-model="dataForm.circulatCard"
                                @press-enter="huiche" />
                        </a-form-item>



                        <a-form-item label="客户名称" :style="{ width: '300px' }" label-col-flex="80px">
                            <a-input allow-clear class="bacClass" placeholder="" v-model="dataForm.customName"
                                @press-enter="huiche" />
                        </a-form-item>
                        <a-form-item label="布号" :style="{ width: '300px' }" label-col-flex="80px">
                            <a-input allow-clear class="bacClass" placeholder="" v-model="dataForm.clothCode"
                                @press-enter="huiche" />
                        </a-form-item>

                        <a-form-item label="品名" :style="{ width: '300px' }" label-col-flex="80px">
                            <a-input allow-clear class="bacClass" placeholder="" v-model="dataForm.brandName"
                                @press-enter="huiche" />
                        </a-form-item>
                        <a-form-item label="色号" :style="{ width: '300px' }" label-col-flex="80px">
                            <a-input allow-clear class="bacClass" placeholder="" v-model="dataForm.colorCode"
                                @press-enter="huiche" />
                        </a-form-item>
                        <a-form-item label="色称" :style="{ width: '300px' }" label-col-flex="80px">
                            <a-input allow-clear class="bacClass" placeholder="" v-model="dataForm.colorName"
                                @press-enter="huiche" />
                        </a-form-item>
                        <a-form-item label="计划单号" :style="{ width: '300px' }" label-col-flex="80px">
                            <a-input allow-clear class="bacClass" placeholder="" v-model="dataForm.planOrderCode"
                                @press-enter="huiche" />
                        </a-form-item>
                    </a-form>
                </div>
                <div class="my-tool-bar">
                    <Toolbar :items="['查询', '新增', '删除']" @del="shanchu" @select="cx" @add="addTz">
                    </Toolbar>



                </div>
            </div>
            <div class="my-divisders">
                <a-divider orientation="center">
                    <icon-double-up v-if="headerShow" @click="headerShow = false" :strokeWidth="2" :size="18" />
                    <icon-double-down v-else @click="headerShow = true" :strokeWidth="2" :size="18" />
                </a-divider>
            </div>
        </template>
        <template #pageTabel>
            <a-spin :loading="pageData2.pageLoading" tip="加载中" dot style="height:100%;width: 100%;z-index:999 ;">
                <AgGridVuesCopys :rowHeight="33" :headerHeight="33" :suppressCopyRowsToClipboard="true" :localeText="localeText1"
                    rowSelection="multiple" @grid-ready="gridReady" style="height:100%" :defaultColDef="defaultColDef"
                    class='ag-theme-alpine' :rowData="table.dataList" :columnDefs="tc">
                </AgGridVuesCopys>
            </a-spin>
            <!-- </a-tab-pane>
                                                            </a-tabs> -->
        </template>
        <paginationCopys :total="total" show-total show-jumper show-page-size @change="PageSize" @page-size-change="change1"
            style="justify-content: center" :page-size="pagination.pageSize" :current="pagination.page" />
        <a-drawer ok-text='保存' cancel-text='关闭' :style="{ zIndex: 999 }" height="100%" :mask-closable="false"
            popup-container=".table-page-body" placement="bottom" :visible="pageData.showAdd" unmountOnClose @ok="sideOk"
            @cancel="sideNo">
            <template #title>
                {{ pageData.sideTitle }}
            </template>
            <a-form style="margin-top:30px" :model="querDatas" size="small" layout="inline">
                <a-form-item label="记录单号" :style="{ width: '300px' }" label-col-flex="100px">
                    <a-input allow-clear class="bacClass" placeholder="" v-model="dataForm2.recordCode"
                        @press-enter="huiche" disabled />
                </a-form-item>
                <a-form-item label="开单日期" :style="{ width: '300px' }" label-col-flex="100px">
                    <a-date-picker  popup-container="html"  :disabled="isDetails" allow-clear class="bacClass" placeholder=""
                        v-model="dataForm2.recordDate" @press-enter="huiche" />
                </a-form-item>
                <a-form-item label="流转卡号" :style="{ width: '300px' }" label-col-flex="100px">
                    <!-- <a-select popup-container="html"   :disabled="isDetails" @change="getInfo" :class="{ 'bacClass': (!pageData.isDetails) }" allow-clear allow-search
                                         v-model="dataForm2.circulatCard" @focus="getliuzhuanka">
                                        <a-option v-for="item in dataForm2.circulatCardList" :value="item.flowCardCode">
                                            {{ item.flowCardCode }}
                                        </a-option>
                                    </a-select> -->
                    <a-input placeholder="扫瞄或输入" :disabled="isDetails" allow-clear class="bacClass"
                        v-model="dataForm2.circulatCard" @press-enter="huiche2">
                        <template #suffix>
                            <icon-scan style="position:relative;left:-5px" />
                        </template>
                    </a-input>
                </a-form-item>
                <a-form-item label="生产车间" :style="{ width: '300px' }" label-col-flex="100px">
                    <!-- <a-select popup-container="html"  :class="{ 'bacClass': (!pageData.isDetails) }" allow-clear allow-search
                                        v-model="dataForm2.shengchangchejian" @focus="getchejian">
                                        <a-option v-for="item in dataForm2.shengchangchejianlist" :value="item.fabricType">
                                            {{ item.fabricType }}
                                        </a-option>
                                    </a-select> -->
                    <a-cascader @change="gaibian" @focus="getchejian" v-model="dataForm2.shengchangchejian"
                        :options="dataForm2.shengchangchejianlist" :style="{ width: '240px' }" class="bacClass"
                        check-strictly :disabled="sccjindex" popup-container="html"/>
                </a-form-item>

                <!-- <a-form-item label="备注" :style="{ width: '624px' }" label-col-flex="100px">
                    <a-textarea :disabled="isDetails" class="bacClass" placeholder="" v-model="dataForm2.remark"
                        :max-length="400" allow-clear show-word-limit />
                </a-form-item> -->
                <a-form-item :style="{ width: '624px', 'position': 'relative', 'top': '10px' }">
                    <!-- <a-button @click="addLKK" type="primary" size="mini"
                                            style="margin-right:10px">添加</a-button>
                                        
                                        <a-button @click="delLZK" type="primary" status="danger" size="mini">删除</a-button> -->
                </a-form-item>
            </a-form>

            <a-table size="mini" :scrollbar="true" sticky-header :style="{ height: '100%', 'margin-top': '20px' }" stripe
                :bordered="{ cell: true }" :row-selection="{ showCheckedAll: true, width: 50 }" :pagination="false"
                v-model:selected-keys="selectedRowKeysDX" rowKey="id" :columns="tableColumns2" :data="dataForm2.DXlist">


                <template #reductSlope="{ record }">
                    <a-input allow-clear class="bacClass" placeholder="" v-model="record.reductSlope"
                        :disabled="isDetails" />
                </template>



                <template #firstGreyWashWidth="{ record }">
                    <a-input-number v-model="record.firstGreyWashWidth" :step="1" class="bacClass" :min="-1000000"
                        :disabled="isDetails" :max="1000000" />

                </template>
                <template #firstGreyWashWeight="{ record }">
                    <a-input-number v-model="record.firstGreyWashWeight" :step="1" class="bacClass" :min="-1000000"
                        :disabled="isDetails" :max="1000000" />

                </template>
                <template #firstGreyWashCPI="{ record }">
                    <!-- <a-input-number v-model="record.firstGreyWashCPI" :step="1" class="bacClass" :min="-1000000"
                           :disabled="isDetails"  :max="1000000" /> -->
                    <a-input allow-clear class="bacClass" placeholder="" v-model="record.firstGreyWashCPI"
                        :disabled="isDetails" />

                </template>
                <template #afterGreyWashWidth="{ record }">
                    <a-input-number v-model="record.afterGreyWashWidth" :step="1" class="bacClass" :min="-1000000"
                        :disabled="isDetails" :max="1000000" />

                </template>
                <template #afterGreyWashWeight="{ record }">
                    <a-input-number v-model="record.afterGreyWashWeight" :step="1" class="bacClass" :min="-1000000"
                        :disabled="isDetails" :max="1000000" />

                </template>
                <template #remark="{ record }">
                    <a-input allow-clear class="bacClass" placeholder="" v-model="record.remark" :disabled="isDetails" />
                </template>
            </a-table>
        </a-drawer>
        <a-modal v-model:visible="visible1" title="流转卡信息" @ok="addLKK" ok-text="添加" :width="1000" draggable>
            <a-button type="primary" @click="cxliuzhuanka" size="mini">查询</a-button>
            <a-table v-model:selected-keys="selectedRowKeys" stripe :bordered="true" :columns="tableColumnsLZK" size="mini"
                :row-selection="{ showCheckedAll: true, width: 50 }" rowKey="id" :loading="table.tableLoading"
                :data="dataForm2.LZKlist" :pagination="false">
            </a-table>
        </a-modal>
    </pageTabelLayout>
</template>
<script lang='ts' setup>
import { number } from 'echarts/core';
import { reactive, toRefs, ref } from 'vue'
import { useTable, useRowKey, useTableColumn, usePagination, useRowSelection } from '@/hooks/table'
import { post } from '@/api/http'
import { url } from 'inspector';

import { Message, Modal } from '@arco-design/web-vue';
import { IconDoubleUp, IconDoubleDown } from '@arco-design/web-vue/es/icon';
import { localeText } from '@/api/aggridZw'
import WHService, { Warhouse, CompanyList, WhTypeField } from '@/service/wh'
import { slicing } from '@/utils/caseFrimAndSecRig'
const localeText1: any = ref(localeText)

const queryData: any = reactive({
    firm: "",
    clothType: ""
});
const pageData2 = reactive({
    pageLoading: false
})
const isDetails = ref(false)
const selectedRowKeys = ref([])
const selectedRowKeysDX = ref([])
const visible1 = ref(false)
const gaibian = () => {
    console.log(dataForm2.shengchangchejian);
    sccjindex.value = true
}
const dataForm: any = reactive({
    beginDate: "",
    endDate: '',
    recordCode: "",
    circulatCard: "",
    customName: "",
    clothCode: "",
    brandName: "",
    colorCode: "",
    colorName: "",
    planOrderCode: ""

})
const dataForm2: any = reactive({
    recordCode: "",
    beginDate: "",
    endDate: '',
    circulatCard: "",
    circulatCardList: [] as any,
    shengchangchejian: "",
    shengchangchejianlist: [] as any,
    remark: "",
    DXlist: [] as any,
    LZKlist: [] as any,
    shengchangchejianName: ''

})

const addDX = () => {
    // getTakeInfo();
    if (dataForm2.circulatCard == "") {
        Message.error({
            content: "请先选择流转卡号！！！",
            duration: 5000,
        });
        return
    }
    visible1.value = true
}
const delLZK = () => {
    selectedRowKeysDX.value.map((o: any) => {
        dataForm2.DXlist.splice(dataForm2.DXlist.findIndex((item: any) => item.id === o.id), 1);
    })

    selectedRowKeysDX.value = [];

}
const addLKK = () => {
    if (dataForm2.DXlist == null || dataForm2.DXlist == undefined) {
        Message.error({
            content: "请先选择流转卡",
            duration: 5000,
        });
        return;
    }
    console.log(selectedRowKeys.value);
    console.log(selectedRowKeys.value[0])
    getTakeInfo();
    selectedRowKeys.value = [];

}
const cxliuzhuanka = () => {
    post({
        url: 'aps/circulatCard/getCardAndOrderInfo',
        data: { flowCardCode: dataForm2.circulatCard }
    }).then((res: any) => {
        if (res.code == 200) {
            dataForm2.LZKlist = res.data;
        }
    })
}
//生产车间
const getchejian = () => {
    post({
        url: 'org/baCompany/getTreeCompanyByUser',
    }).then(({ code, data }) => {
        if (code === 200) {
            console.log(data)
            dataForm2.shengchangchejianlist = data
        }
    })
}
const getliuzhuanka = () => {
    post({
        // url: "aps/circulatCard/getDropValue",
        url: "aps/schedulOrder/getDropValue",
        data: { flowCardCode: "" }
    }).then(({ data, code, message }: any) => {
        if (code === 200) {
            dataForm2.circulatCardList = data;
        } else {
            Message.error({
                content: message,
                duration: 5000,
            });
        }
    });
}
const pageData: any = reactive({
    showAdd: false,
    sideTitle: '新增'
})
onMounted(() => {
})
const querDatas = ref({})

const sideOk = () => {

    // dataForm2.DXlist[0]['workShopId']=dataForm2.shengchangchejian

    if (pageData.sideTitle == '新增') {
        dataForm2.shengchangchejianlist.forEach((item: any) => {
            if (item.value == dataForm2.shengchangchejian) {
                dataForm2.shengchangchejianName = item.name
            }
        })
        if (dataForm2.DXlist.length === 0) {
            Message.error({
                content: '明细数据为空无法保存!',
                duration: 5000,
            })
            return
        } else {
            dataForm2.DXlist.map((o: any) => {
                o['id'] = ""
                o['workShopId'] = dataForm2.shengchangchejian
                o['workShopName'] = dataForm2.shengchangchejianName
                o['recordCode'] = dataForm2.recordCode
                o['recordDate'] = dataForm2.recordDate
            })
            post({
                url: '/dwWorkShop/StereotypeReduct/insertList',
                data: dataForm2.DXlist
            }).then((res: any) => {
                if (res.code == 200) {
                    Message.success({
                        content: res.message,
                        duration: 5000,
                    })
                    pageData.showAdd = false
                    doRefresh();
                } else {
                    Message.error({
                        content: res.message,
                        duration: 5000,
                    })
                }
            })
        }

    } else if (pageData.sideTitle == '修改') {
        dataForm2.DXlist.map((o: any) => {
            o['workShopId'] = dataForm2.shengchangchejian
            o['workShopName'] = dataForm2.shengchangchejianName
            o['recordCode'] = dataForm2.recordCode
            o['recordDate'] = dataForm2.recordDate
        })
        post({
            url: '/dwWorkShop/StereotypeReduct/updateList',
            data: dataForm2.DXlist
        }).then((res: any) => {
            if (res.code == 200) {
                Message.success({
                    content: res.message,
                    duration: 5000,
                })
                pageData.showAdd = false
                doRefresh();
            } else {
                Message.error({
                    content: res.message,
                    duration: 5000,
                })

            }
        })
    }

}

const sideNo = () => {
    pageData.showAdd = false
}

const addTz = () => {
    pageData.showAdd = true
    pageData.sideTitle = '新增'
    isDetails.value = false
    sccjindex.value = false
    dataForm2.shengchangchejian = null;
    dataForm2.shengchangchejianName = ''
    dataForm2.recordDate = ""
    dataForm2.circulatCard = ""
    dataForm2.remark = ""
    dataForm2.DXlist = [];
    post({
        url: '/dwWorkShop/StereotypeReduct/getCodeGenerate',
    }).then((res: any) => {
        if (res.code == 200) {
            dataForm2.recordCode = res.data
        }
    })

}

const headerShow = ref<boolean>(true)
function doRefresh() {
    pageData2.pageLoading = true
    post({
        url: '/dwWorkShop/StereotypeReduct/getPage',
        data: {
            page: pagination.page,
            size: pagination.pageSize,
            beginDate: dataForm.beginDate,
            endDate: dataForm.endDate,
            recordCode: dataForm.recordCode,
            circulatCard: dataForm.circulatCard,
            customName: dataForm.customName,
            clothCode: dataForm.clothCode,
            brandName: dataForm.brandName,
            colorCode: dataForm.colorCode,
            colorName: dataForm.colorName,
            planOrderCode: dataForm.planOrderCode,
            deleteState: 0
        }
    }).then(({ data, code }: any) => {
        if (code === 200) {
            table.handleSuccess(data.list);

            gridOption.value.setRowData(data.list);
            total.value = data.total;
            console.log(gridOption)
            pageData2.pageLoading = false
        }
    })
        .catch(console.log);
}
const handleOk = () => {
    console.log(66666)
}
const shanchu = () => {
    if (gridOption.value.getSelectedRows().length === 0) {
        Message.error({
            content: '请先勾选',
            duration: 5000,
        })
        return
    }
    Modal.confirm({
        title: '系统提示',
        content: '确认删除选中的数据?',
        onOk() {
            post({
                url: '/dwWorkShop/StereotypeReduct/delete',
                data: gridOption.value.getSelectedRows().map((o: any) => {
                    return o.id
                }),
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    Message.success({
                        content: '删除成功',
                        duration: 5000,
                    })
                    pagination.page = 1
                    doRefresh()
                } else {
                    Message.error({
                        content: '删除失败',
                        duration: 5000,
                    })
                }
            })

        }
    })
}
const getInfo = () => {
    console.log(dataForm2.circulatCard);

}
const getTakeInfo = () => {

    post({
        url: 'aps/circulatCard/getList',
        data: { flowCardCode: dataForm2.circulatCard }
    }).then((res: any) => {
        if (res.code == 200) {
            res.data.map((o: any) => {

                var obj = {
                    "id": o.id,
                    "recordCode": dataForm2.recordCode,
                    "circulatCard": o.flowCardCode,
                    "workShopId": dataForm2.shengchangchejian,
                    "customName": o.customName,
                    "contractNo": o.contrastColor,
                    "customOrderCode": o.customOrderName,
                    "clothCode": o.clothCode,
                    "brandName": o.brandName,
                    "colorCode": o.colorCode,
                    "colorName": o.colorName,
                    "greyCode": o.greyCode,
                    "greyName": o.greyName,
                    "yarnBatch": o.greyBatch,
                    // "machineCode":"",
                    "requireWidth": 0,
                    "requireWeight": 0,
                    "firstGreyWashWidth": 0,
                    "firstGreyWashWeight": 0,
                    "afterGreyWashWidth": 0,
                    "afterGreyWashWeight": 0,
                    "reductSlope": "",
                    "firstGreyWashCPI": "",
                    "remark": ""
                    //  "creatName":o.createName,
                    //  "creatTime":o.createTime

                }
                dataForm2.DXlist.unshift(obj)
            })
        }
    })
}
const total = ref(10);
const page = ref(1);
const size = ref(10);
function PageSize(val: any) {
    pagination.page = val
    doRefresh();
}
function change1(val: any) {
    pagination.pageSize = val
    doRefresh();
}
const cx = () => {
    pagination.page = 1
    doRefresh()
}


const table = useTable()

const pagination = usePagination(doRefresh)

const tableColumns = useTableColumn([
    {
        title: "记录单号",
        key: "recordCode",
        dataIndex: "recordCode",
        slotName: 'recordCode',
        width: 150,
    },
    {
        title: "记录日期",
        key: "recordDate",
        dataIndex: "recordDate",
        slotName: 'recordDate',
        width: 150,
    },
    {
        title: "流转卡号",
        key: "circulatCard",
        dataIndex: "circulatCard",
        slotName: 'circulatCard',
        width: 150,
    },

    {
        title: "生产车间",
        key: "workShopName",
        dataIndex: "workShopName",
        slotName: 'workShopName',
        width: 150,
    },
    // {
    //     title: "类型",
    //     key: "reductType",
    //     dataIndex: "reductType",
    //     slotName: 'reductType',
    //     width: 150,
    // },
    // {
    //     title: "制单人",
    //     key: "createName",
    //     dataIndex: "createName",
    //     slotName: 'createName',
    //     width: 150,
    // },
    {
        title: "合约号",
        key: "contractNo",
        dataIndex: "contractNo",
        slotName: 'contractNo',
        width: 150,
    },

    {
        title: "客户名称",
        key: "customName",
        dataIndex: "customName",
        slotName: "customName",
        width: 150,
    },
    {
        title: "客户订单号",
        key: "customOrderCode",
        dataIndex: "customOrderCode",
        slotName: "customOrderCode",
        width: 150,
    },
    {
        title: "布号",
        key: "clothCode",
        dataIndex: "clothCode",
        slotName: "clothCode",
        width: 150,
    },
    {
        title: "品名",
        key: "brandName",
        dataIndex: "brandName",
        slotName: "brandName",
        width: 150,
    },
    {
        title: "色号",
        key: "colorCode",
        dataIndex: "colorCode",
        slotName: "colorCode",
        width: 150,
    },
    {
        title: "色称",
        key: "colorName",
        dataIndex: "colorName",
        slotName: "colorName",
        width: 150,
    },
    {
        title: "纱批",
        key: "yarnBatch",
        dataIndex: "yarnBatch",
        slotName: "yarnBatch",
        width: 150,
    },
    {
        title: "坯布编号",
        key: "greyCode",
        dataIndex: "greyCode",
        slotName: "greyCode",
        width: 150,
    },
    {
        title: "坯布名称",
        key: "greyName",
        dataIndex: "greyName",
        slotName: "greyName",
        width: 150,
    },


    {
        title: "客户要求",
        key: "greyName",
        dataIndex: "greyName",
        width: 150,
        children: [
            { title: '门幅', dataIndex: 'requireWidth', width: 150, slotName: "requireWidth" },
            { title: '克重', dataIndex: 'requireWeight', width: 150, slotName: "requireWeight" }
        ]
    },
    {
        title: "还原斜度",
        key: "reductSlope",
        dataIndex: "reductSlope",
        slotName: "reductSlope",
        width: 150,
    },
    {
        title: "坯洗前",
        key: "greyName",
        dataIndex: "greyName",
        width: 150,
        children: [
            { title: '门幅', dataIndex: 'firstGreyWashWidth', width: 150, slotName: "firstGreyWashWidth" },
            { title: '克重', dataIndex: 'firstGreyWashWeight', width: 150, slotName: "firstGreyWashWeight" },
            { title: 'CPI', dataIndex: 'firstGreyWashCPI', width: 150, slotName: "firstGreyWashCPI" }
        ]
    },
    {
        title: "坯洗后",
        key: "greyName",
        dataIndex: "greyName",
        width: 150,
        children: [
            { title: '门幅', dataIndex: 'afterGreyWashWidth', width: 150, slotName: 'afterGreyWashWidth' },
            { title: '克重', dataIndex: 'afterGreyWashWeight', width: 150, slotName: 'afterGreyWashWeight' }
        ]
    },

    {
        title: "建立人",
        key: "createName",
        dataIndex: "createName",
        width: 150,
    },
    {
        title: "建立日期",
        key: "createTime",
        dataIndex: "createTime",
        width: 150,
    },

    {
        title: "操作",
        key: "obsoleteState",
        dataIndex: "obsoleteState",
        slotName: 'obsoleteState',
        width: 150,
        fixed: 'right'
    }
])

const tableColumns2 = useTableColumn([
    {
        title: "流转卡号",
        key: "circulatCard",
        dataIndex: "circulatCard",
        slotName: 'circulatCard',
        width: 150,
    },
    // {
    //     title: "记录单号",
    //     key: "recordCode",
    //     dataIndex: "recordCode",
    //     slotName: 'recordCode',
    //     width: 150,
    // },
    // {
    //     title: "生产车间",
    //     key: "workShopId",
    //     dataIndex: "workShopId",
    //     slotName: 'workShopId',
    //     width: 150,
    // },
    // {
    //     title: "类型",
    //     key: "reductType",
    //     dataIndex: "reductType",
    //     slotName:'reductType',
    //     width: 150,
    // },
    // {
    //     title: "制单人",
    //     key: "createName",
    //     dataIndex: "createName",
    //     slotName: 'createName',
    //     width: 150,
    // },
    {
        title: "合约号",
        key: "contractNo",
        dataIndex: "contractNo",
        slotName: 'contractNo',
        width: 150,
    },

    {
        title: "客户名称",
        key: "customName",
        dataIndex: "customName",
        slotName: "customName",
        width: 150,
    },
    {
        title: "客户订单号",
        key: "customOrderCode",
        dataIndex: "customOrderCode",
        slotName: "customOrderCode",
        width: 150,
    },
    {
        title: "布号",
        key: "clothCode",
        dataIndex: "clothCode",
        slotName: "clothCode",
        width: 150,
    },
    {
        title: "品名",
        key: "brandName",
        dataIndex: "brandName",
        slotName: "brandName",
        width: 150,
    },
    {
        title: "色号",
        key: "colorCode",
        dataIndex: "colorCode",
        slotName: "colorCode",
        width: 150,
    },
    {
        title: "色称",
        key: "colorName",
        dataIndex: "colorName",
        slotName: "colorName",
        width: 150,
    },
    {
        title: "纱批",
        key: "yarnBatch",
        dataIndex: "yarnBatch",
        slotName: "yarnBatch",
        width: 150,
    },
    {
        title: "坯布编号",
        key: "greyCode",
        dataIndex: "greyCode",
        slotName: "greyCode",
        width: 150,
    },
    {
        title: "坯布名称",
        key: "greyName",
        dataIndex: "greyName",
        slotName: "greyName",
        width: 150,
    },


    {
        title: "客户要求",
        key: "greyName",
        dataIndex: "greyName",
        width: 150,
        children: [
            { title: '门幅', dataIndex: 'requireWidth', width: 150, slotName: "requireWidth" },
            { title: '克重', dataIndex: 'requireWeight', width: 150, slotName: "requireWeight" }
        ]
    },
    {
        title: "还原斜度",
        key: "reductSlope",
        dataIndex: "reductSlope",
        slotName: "reductSlope",
        width: 150,
    },
    {
        title: "坯洗前",
        key: "greyName",
        dataIndex: "greyName",
        width: 150,
        children: [
            { title: '门幅', dataIndex: 'firstGreyWashWidth', width: 150, slotName: "firstGreyWashWidth" },
            { title: '克重', dataIndex: 'firstGreyWashWeight', width: 150, slotName: "firstGreyWashWeight" },
            { title: 'CPI', dataIndex: 'firstGreyWashCPI', width: 150, slotName: "firstGreyWashCPI" }
        ]
    },
    {
        title: "坯洗后",
        key: "greyName",
        dataIndex: "greyName",
        width: 150,
        children: [
            { title: '门幅', dataIndex: 'afterGreyWashWidth', width: 150, slotName: 'afterGreyWashWidth' },
            { title: '克重', dataIndex: 'afterGreyWashWeight', width: 150, slotName: 'afterGreyWashWeight' }
        ]
    },
    {
        title: "备注",
        key: "remark",
        dataIndex: "remark",
        width: 300,
        slotName: 'remark'
    },
    // {
    //     title: "建立人",
    //     key: "createName",
    //     dataIndex: "createName",
    //     width: 150
    // },
    // {
    //     title: "建立日期",
    //     key: "createTime",
    //     dataIndex: "createTime",
    //     width: 150
    // },


])
const tableColumnsLZK = reactive([
    {
        title: "流转卡号",
        key: "flowCardCode",
        dataIndex: "flowCardCode",
        slotName: 'flowCardCode',
        width: 150,
    },

    {
        title: "客户名称",
        key: "customName",
        dataIndex: "customName",
        slotName: "customName",
        width: 150,
    },
    {
        title: "合约号",
        key: "contractNo",
        dataIndex: "contractNo",
        slotName: "contractNo",
        width: 150,
    },
    {
        title: "客户订单号",
        key: "customOrderName",
        dataIndex: "customOrderName",
        slotName: "customOrderName",
        width: 150,
    },
    {
        title: "布号",
        key: "clothCode",
        dataIndex: "clothCode",
        slotName: "clothCode",
        width: 150,
    }
])
let tc: any = tableColumns.map((o) => {


    let newshuzu = [] as any
    if (o.children != null || o.children != undefined) {
        o.children.map((d: any) => {
            var m = { headerName: d.title, field: d.dataIndex, pinned: d['fixed'] }
            newshuzu.push(m)
        })
    }


    let obj = {
        headerName: o.title,
        field: o.key,
        pinned: o['fixed'],
    }
    if (o.children != null || o.children != undefined) {
        obj['children'] = newshuzu
    }


    if (o.slotName === 'obsoleteState') {
        obj['resizable'] = false
        obj['filter'] = false
        obj['sortable'] = false
        obj["lockPosition"] = "right"
        obj["width"] = 150
        obj['cellRenderer'] = {
            template: `<a-space><el-button  type="info" link  style="color:#165dff;" @click="a">修改</el-button>
            
           
           </a-space> `,
            setup(props: any) {

                const a = () => {
                    editHandler(props.params.data, 1)
                }
                const b = () => {
                    editHandler(props.params.data, 2)
                }
                return {
                    a,
                    b
                }
            }

        }
    }

    return obj
})

let a = [{
    showRowGroup: 'hide_def',
    "headerName": "",
    "checkboxSelection": true,
    "headerCheckboxSelection": true,
    "pinned": "left",
    "width": 50,
    resizable: false,
    filter: false,
    sortable: false,
    minWidth: 50,
    maxWidth: 50,
    //lockPosition: "left",
}]
tc = a.concat(tc)

const dataList = ref('1')
// 表格准备事件
const gridOption = ref()
const gridReady = (params: any) => {
    gridOption.value = params.api
}
const newlie = ref([])
const defaultColDef = {
    sortable: true,
    resizable: true,
    filter: true,
    // flex: 1
}
const huiche = () => {
    doRefresh();
}
const editHandler = (val: any, jihao: any) => {
    post({
        url: 'org/baCompany/getTreeCompanyByUser',
    }).then(({ code, data }) => {
        if (code === 200) {
            //console.log(data)
            dataForm2.shengchangchejianlist = data
        }
    })
    console.log(val, jihao)
    if (jihao == 1) {
        pageData.sideTitle = '修改'
        getDxDetails({ circulatCard: val.circulatCard, id: val.id });
        pageData.showAdd = true
        isDetails.value = false


    } else {
        pageData.sideTitle = '明细'
        pageData.showAdd = true
        getDxDetails({ circulatCard: val.circulatCard, id: val.id });
        isDetails.value = true
    }
}
const getDxDetails = (val: any) => {
    post({
        url: '/dwWorkShop/StereotypeReduct/getList',
        data: val
    }).then((res: any) => {
        if (res.code == 200) {
            // console.log(res);
            dataForm2.circulatCard = res.data[0].circulatCard
            dataForm2.recordDate = res.data[0].recordDate
            dataForm2.recordCode = res.data[0].recordCode
            dataForm2.shengchangchejian = Number(res.data[0].workShopId)
            dataForm2.remark = res.data[0].remark
            dataForm2.DXlist = res.data
            console.log(dataForm2.shengchangchejian);
        }
    })

}
const sccjindex = ref(false)
const huiche2 = (val: any) => {
    post({
        url: '/dwWorkShop/StereotypeReduct/getCirulatCard',
        data: { circulatCard: dataForm2.circulatCard }
    }).then((res: any) => {
        if (res.code == 200) {
            dataForm2.DXlist = res.data
        }
    })
}
</script>
<style lang='less' scoped>
.search-form {
    margin-top: 10px;
}

.toolbar-item {
    cursor: pointer;
}

.toolBarRig {
    margin-left: 80%
}

.fromTitle {
    width: 100%;
    background-color: white;
    padding: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: row;
    justify-content: space-between;

    form {
        width: 50% !important;
        margin-top: 10px !important;
    }

    &>.my-header {
        width: 100%;
        padding: 10px;
        padding-top: 0;
        background-color: white;


        min-height: 10%;

        &>.my-tool-bar {
            width: 100%;
            text-align: right;
            margin-top: 50px;
        }
    }
}

.fromTitle1 {
    margin-left: 50px;
    margin-top: 60px;
}

:deep(.ag-cell-value) {
    user-select: initial;
    -moz-user-select: text;
    -ms-user-select: text;
    -webkit-user-select: text;
    text-align: center;
}

:deep(.ag-cell) {
    border-right: 1px solid #dde2eb;
}

:deep(.ag-header-cell) {
    border-right: 1px solid #dde2eb;
}

:deep(.ag-header-group-cell) {
    border-right: 1px solid #dde2eb;
}
</style>